# demo04_str.py
s4 = "hello.tar.gz"
data = s4.split("tar")  # 切割
print("data:", data)  # ['hello.', '.gz']
data1 = "__".join(["hello", "tar", "gz"])  # 连接
print(data1)  # hello__tar__gz

s1, s2 = "hello world", "HELLO WORLD"
print(s1.startswith("hel"), s1.endswith("hehe"))
print(s1.islower(), s2.isupper())
s3 = "    hehe  xixxi    \n "
print(s3.lstrip())  # l: left
print(s3.rstrip())  # r: right
print(s3.strip())   # 去除左右两边空白字符


name, age = "benben", 64
# 目标:     name: benben, age: 64
str01 = "name: " + name + ", age: " + str(age)
print(str01)  # name: benben, age: 64
# 字符串格式化: 挖坑 填坑
# %s: 先挖坑，再填坑
str02 = "name: %s, age: %s" % (name, age)
print(str02)
# f字符串: 3.6+, 边挖坑边填坑
str03 = f"name: {name}, age: {age}"
print(str03)


